package com.yuda.tools.checkanswer.Oss;

import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ConditionalOnProperty(name = "check.oss_inner_out", havingValue = "-outer",matchIfMissing = true)
@Configuration
public class OssConfigOuter {

    private final String outer = "-outer";

    @Value("${spring.cloud.alicloud.access-key}")
    private String accessKey;

    @Value("${spring.cloud.alicloud.secret-key}")
    private String accessSecret;


    @Bean
    public OSS ossClientHuaDongOuter() {
        ClientBuilderConfiguration config = new ClientBuilderConfiguration();
        config.setMaxConnections(5000);
        OSS build = new OSSClientBuilder().build("oss-cn-hangzhou.aliyuncs.com", accessKey, accessSecret,config);
        OssMap.put("huadongpaper" + outer, build);
        return build;
    }

    @Bean
    public OSS ossClientHuaNanOuter() {
        ClientBuilderConfiguration config = new ClientBuilderConfiguration();
        config.setMaxConnections(5000);
        OSS build = new OSSClientBuilder().build("oss-cn-shenzhen.aliyuncs.com", accessKey, accessSecret,config);
        OssMap.put("huananpaper" + outer, build);
        return build;
    }


    @Bean
    public OSS ossClientBeiJingOuter() {
        ClientBuilderConfiguration config = new ClientBuilderConfiguration();
        config.setMaxConnections(5000);
        OSS build = new OSSClientBuilder().build("oss-cn-beijing.aliyuncs.com", accessKey, accessSecret,config);
        OssMap.put("beijingpaper" + outer, build);
        return build;
    }

    @Bean
    public OSS ossClientZhongYuanOuter() {
        ClientBuilderConfiguration config = new ClientBuilderConfiguration();
        config.setMaxConnections(5000);
        OSS build = new OSSClientBuilder().build("oss-cn-qingdao.aliyuncs.com", accessKey, accessSecret,config);
        OssMap.put("zhongyuanpaper" + outer, build);
        return build;
    }


    @Bean
    public OSS ossClientDefanswerOuter() {
        ClientBuilderConfiguration config = new ClientBuilderConfiguration();
        config.setMaxConnections(5000);
        OSS build = new OSSClientBuilder().build("oss-cn-qingdao.aliyuncs.com", accessKey, accessSecret,config);
        OssMap.put("defanswer" + outer, build);
        return build;
    }

}
